package org.smile.db.handler;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.Map;
/**
 * 把一行结果集处理成一个Map的实现
 * 
 * @author strive
 *
 */
public class MapRowHandler implements RowHandler {

	/**
	 * 实现接口方法
	 */
	public Object handle(ResultSet rs) throws SQLException {
		Map<String, Object> result = new ResultSetMap();
        ResultSetMetaData rsmd = rs.getMetaData();
        int cols = rsmd.getColumnCount();
        for (int i = 1; i <= cols; i++) {
        	String columnName = rsmd.getColumnLabel(i);
            Object value = rs.getObject(columnName);
            result.put(columnName.toLowerCase(), value);
        }
        return result;
	}

}
